package com.gxa.controller;

import com.gxa.common.LayR;
import com.gxa.common.R;
import com.gxa.param.MyTableParam;
import com.gxa.pojo.Baseinfo;
import com.gxa.pojo.Notice;
import com.gxa.service.baseInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;

/**
 * @author xiejinfeng
 * @create 2021-06-15 21:07
 * @descrip:
 */
@Controller
@RequestMapping("/baseInfo")
public class baseInfoController {

    @Autowired
    private baseInfoService service;

    @PostMapping("/list/Pagedata")
    @ResponseBody
    public LayR list1(MyTableParam param){
        return service.list(param);
    }

    @GetMapping("/list/page")
    public String listPage(){
        return "baseInfo/baseInfo-list";
    }

    @PostMapping("/deleteOne")
    @ResponseBody
    public R deleteOne(Integer id){

        return service.deleteOne(id);
    }

    @PostMapping("/delete")
    @ResponseBody
    public R delete(String[] baseInfoIds){
        return service.deleteAll(baseInfoIds);
    }

    @GetMapping("/add/page")
    public String addPage(){
        return "baseInfo/baseInfo-add";
    }

    @PostMapping("/add/do")
    @ResponseBody
    public R add(Baseinfo baseinfo){

        return service.add(baseinfo);

    }

    @GetMapping("/edit/page")
    public String editPage(Integer id, Model model){
        model.addAttribute("baseInfoId", id);
        return "baseInfo/baseInfo-edit";
    }

    @PostMapping("/detail")
    @ResponseBody
    public R detail(Integer id){
        return service.findById(id);
    }

    @PostMapping("/edit/do")
    @ResponseBody
    public R edit(Baseinfo baseinfo){

        return service.edit(baseinfo);
    }

}
